package model

import (
	"manager/model/entity"
)

// UpgradeRecordCreateRequest 创建现场数据
type UpgradeRecordCreateRequest struct {
	FirmwareId int64 `json:"firmware_id"`

	FirmwaresName string `json:"firmwares_name"`

	Version string `json:"version"`

	TacticsId int64 `json:"tactics_id"`

	SnCode string `json:"sn_code"`

	Status int `json:"status"`

	Desc string `json:"desc"`

	UpdatedAt int64 `json:"updated_at"`
}

// UpgradeRecordUpdateRequest 更新现场数据
type UpgradeRecordUpdateRequest struct {
	Id int64 `json:"id"`

	FirmwareId *int64 `json:"firmware_id"`

	FirmwaresName *string `json:"firmwares_name"`

	Version *string `json:"version"`

	TacticsId *int64 `json:"tactics_id"`

	SnCode *string `json:"sn_code"`

	Status *int `json:"status"`

	Desc *string `json:"desc"`

	CreatedAt int64 `json:"created_at"`

	UpdatedAt *int64 `json:"updated_at"`
}

// UpgradeRecordListRequest 列表现场数据
type UpgradeRecordListRequest struct {
	Index int `json:"index"`
	Size  int `json:"size"`

	Id int64 `json:"id"`

	FirmwareId *int64 `json:"firmware_id"`

	FirmwaresName *string `json:"firmwares_name"`

	Version *string `json:"version"`

	TacticsId *int64 `json:"tactics_id"`

	SnCode *string `json:"sn_code"`

	Status *int `json:"status"`

	Desc *string `json:"desc"`

	UpdatedAt *int64 `json:"updated_at"`
}

// UpgradeRecordListResponse 列表回包数据
type UpgradeRecordListResponse struct {
	Total int                  `json:"total"`
	List  []*UpgradeRecordInfo `json:"list"`
}

// UpgradeRecordInfoRequest 列表现场数据
type UpgradeRecordInfoRequest struct {
	Id int64 `json:"id"`

	FirmwareId *int64 `json:"firmware_id"`

	FirmwaresName *string `json:"firmwares_name"`

	Version *string `json:"version"`

	TacticsId *int64 `json:"tactics_id"`

	SnCode *string `json:"sn_code"`

	Status *int `json:"status"`

	Desc *string `json:"desc"`

	UpdatedAt *int64 `json:"updated_at"`
}

// UpgradeRecordInfo 详细数据
type UpgradeRecordInfo struct {
	Id int64 `json:"id"`

	FirmwareId int64 `json:"firmware_id"`

	FirmwaresName string `json:"firmwares_name"`

	Version string `json:"version"`

	TacticsId int64 `json:"tactics_id"`

	SnCode string `json:"sn_code"`

	Status int `json:"status"`

	Desc string `json:"desc"`

	CreatedAt int64 `json:"created_at"`

	UpdatedAt int64 `json:"updated_at"`
}

// UpgradeRecordDeleteRequest 删除现场数据
type UpgradeRecordDeleteRequest struct {
	Id int64 `json:"id"`
}

// UpgradeRecordsEntityToDto entity数据转换
func UpgradeRecordsEntityToDto(upgradeRecords []*entity.UpgradeRecord) []*UpgradeRecordInfo {
	out := make([]*UpgradeRecordInfo, 0, len(upgradeRecords))
	for _, c := range upgradeRecords {
		out = append(out, UpgradeRecordEntityToDto(c))
	}
	return out
}

// UpgradeRecordEntityToDto entity数据转换
func UpgradeRecordEntityToDto(e *entity.UpgradeRecord) *UpgradeRecordInfo {
	return &UpgradeRecordInfo{

		Id: e.Id,

		FirmwareId: e.FirmwareId,

		FirmwaresName: e.FirmwaresName,

		Version: e.Version,

		TacticsId: e.TacticsId,

		SnCode: e.SnCode,

		Status: e.Status,

		Desc: e.Desc,

		CreatedAt: e.CreatedAt,

		UpdatedAt: e.UpdatedAt,
	}
}
